package com.gpframework.module.wages.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.wages.domain.GzTransfer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @ClassName GzTransferReq
 * @Author gpframework
 * @Date 2024-01-22
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class GzTransferReq extends BaseReq {
    private static final long serialVersionUID = 1L;

         @ApiModelProperty("月份")
         @JsonFormat(pattern = "yyyy-MM")
     private Date month;
     @ApiModelProperty("部门")
     private String departmentName;
     @ApiModelProperty("名字")
     private String name;
    @ApiModelProperty("1档口及办公室工资2中转3仓库（其他数字根据需求变化）")
    private Integer departmentType;
    @ApiModelProperty("是否上报")
    private Long escalation;
    @ApiModelProperty("审核及批准")
    private Long examineAndApprove;
    @ApiModelProperty("是否打印")
    private Long print;
    /**
    * @Description 生成查询wrapper
    * @Author greatplan@qq.com
    * @Date 2020-11-04 16:04
    * @Param [lqw]
    * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
    * @Return void
    */
    public void generatorQuery(QueryWrapper<GzTransfer> lqw,boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias+"del_status",0);
        }
        if (this.getMonth() != null){
        lqw.eq(alias+"month" ,this.getMonth());
        }
        if (this.getEscalation() != null){
            lqw.eq(alias+"escalation" ,this.getEscalation());
        }
        if (this.getExamineAndApprove() != null){
            lqw.eq(alias+"examine_and_approve" ,this.getExamineAndApprove());
        }
        if (this.getPrint() != null){
            lqw.eq(alias+"print" ,this.getPrint());
        }
        if (StringUtils.isNotBlank(this.getDepartmentName()) ){
            lqw.in(alias+"department_name" ,this.getDepartmentName().split(","));
        }

        if (StringUtils.isNotBlank(this.getName())){
            lqw.like(alias+"name",this.getName());
        }
    }
}
